
//定义每个切块大小
const chunkSize=1024*1024*5  //5M一个单位划分
 

const cuts=(e,k)=>{
 return new Promise((reslove,reject)=>{
    const chunkCounts=Math.ceil(e.size/chunkSize) //算出切片数量
    const result=[] //分片的信息
    for(let i=0;i<chunkCounts;i++){
     createChunk(file,i,chunkSize,k).then(res=>{
        console.log(res,'rrr')
     })
    }
    reslove(chunkCounts)
 })
}




const createChunk=(file,index,chunkSize,k)=>{
//   console.log(file,index,chunkSize,'oiop')
  return new Promise((resolve,reject)=>{
    const start=index*chunkSize
    const end=start+chunkSize
    const reader=new FileReader()
    reader.readAsDataURL(file.files[0])
    reader.onload=(e)=>{
        k.append(e.target.result)
        resolve({
            hash:k.end(),
            end,
            start
        })
    }
  })
}